package com.zzc.zzcapi.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzc.zzcapi.common.ErrorCode;
import com.zzc.zzcapi.exception.BusinessException;
import com.zzc.zzcapi.mapper.UserInterfaceInfoMapper;
import com.zzc.zzcapi.model.dto.interfaceInfo.InterfaceInfoQueryRequest;
import com.zzc.zzcapi.model.dto.userInterfaceInfo.UserInterfaceInfoQueryRequest;
import com.zzc.zzcapi.model.entity.InterfaceInfo;
import com.zzc.zzcapi.model.entity.UserInterfaceInfo;
import com.zzc.zzcapi.model.vo.InterfaceInfoVO;
import com.zzc.zzcapi.service.UserInterfaceInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
* @author Lenovo
* @description 针对表【user_interface_info(用户调用接口关系)】的数据库操作Service实现
* @createDate 2024-04-26 19:13:02
*/
@Service
public class UserInterfaceInfoServiceImpl extends ServiceImpl<UserInterfaceInfoMapper, UserInterfaceInfo>
    implements UserInterfaceInfoService {

    @Override
    public void validInterfaceInfo(UserInterfaceInfo interfaceInfo, boolean b) {

    }

    @Override
    public InterfaceInfoVO getInterfaceInfoVO(UserInterfaceInfo interfaceInfo, HttpServletRequest request) {
        return null;
    }

    @Override
    public Wrapper<UserInterfaceInfo> getQueryWrapper(UserInterfaceInfoQueryRequest userinterfaceInfoQueryRequest) {
        if(userinterfaceInfoQueryRequest == null) {
            throw new BusinessException(ErrorCode.SYSTEM_ERROR);
        }

        Long id = userinterfaceInfoQueryRequest.getId();
        Long userid = userinterfaceInfoQueryRequest.getUserId();
        Long interfaceinfoid = userinterfaceInfoQueryRequest.getInterfaceInfoId();
        Integer totalnum = userinterfaceInfoQueryRequest.getTotalNum();
        Integer leftnum = userinterfaceInfoQueryRequest.getLeftNum();

        QueryWrapper<UserInterfaceInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", id);
        queryWrapper.eq("userId", userid);
        queryWrapper.eq("interfaceinfoid", interfaceinfoid);
        queryWrapper.eq("interfaceinfoid", interfaceinfoid);
        return queryWrapper;
    }
}




